<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('peisetting'.$merchid,$postdata);
		exi('设置成功');
	}
	$footernav =array(
		array('title'=>'中心','icon'=>'icon-shouye','action'=>'jy_peimilk/index/'),
		array('title'=>'配送费','icon'=>'icon-dixiaofei','action'=>'jy_peimilk/order_log/'),
		array('title'=>'抢单','icon'=>'icon-jisutuikuan','action'=>'jy_peimilk/peisong_order/'),
		array('title'=>'我客户','icon'=>'icon-viewlist','action'=>'jy_peimilk/orderuser/'),
		array('title'=>'我配送','icon'=>'icon-dingdan','action'=>'jy_peimilk/sendlog/'),
	);
	$return['item']=$this->plugin_setting('peisetting'.$merchid);
	$return['item']['footernav']=$return['item']['footernav']?:$footernav;
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基础设置',
				'list'=>array(
					array('type'=>'radio','title'=>'成为配送员条件','name'=>'become_child','options'=>'become_child'),
					array('type'=>'radio','title'=>'配送费计算方式','name'=>'peifeetype','options'=>'peifeetype','help'=>''),
					array('type'=>'radio','title'=>'显示配送费方式','name'=>'peifeeshow','options'=>'peifeeshow','help'=>''),
					array('type'=>'time_onehour','title'=>'配送改签设置','name'=>'gai_peihour','help'=>'配送改签需要每天***点钟前才能改签，改签后第二天按照改签信息配送商品'),
					array('type'=>'switch','title'=>'配送员是否需要审核？','name'=>'become_check','isradio'=>1),
					array('type'=>'switch','title'=>'是否需要完善配送员资料？','name'=>'become_reg','isradio'=>1),
					array('type'=>'switch','title'=>'是否支持转单给其他配送员？','name'=>'is_zhuan','isradio'=>1),
				)
			),
			array(
				'title'=>'结算设置',
				'list'=>array(
					array('type'=>'choose_many','name'=>'admin_ids','title'=>'通知管理员','choose_title'=>'选择通知人','help'=>'如不填写，则不发送结算通知给管理员','action'=>'core/member.get_member/many'),
					array('type'=>'checkbox','title'=>'支持的提现方式','name'=>'withdrawtype','options'=>'withdraw'),
					array('type'=>'string','title'=>'结算额度（元）','name'=>'balance_money','help'=>'配送费达到该数值才能结算'),
					array('type'=>'string','title'=>'配送管理费（%）','name'=>'balance_per'),
					array('type'=>'string','title'=>'结算天数','name'=>'balance_day','help'=>'当订单完成后的n天后，配送费才能申请提现,设置0或空，订单完成就可以结算'),
				),
			),
			array(
				'title'=>'配送员升级设置',
				'list'=>array(
						array('type'=>'switch','title'=>'满足其中一个条件就升级','name'=>'is_level_up_one','isradio'=>1,'help'=>'默认，勾选的条件都要满足才行！'),
						array('type'=>'checkbox','title'=>'配送员升级依据','name'=>'level_up_types','options'=>'leveltype','help'=>''),
					)
			),
			/*array(
				'title'=>'配送订单奖励设置',
				'list'=>array(
						array('type'=>'switch','name'=>'orderfee_open','title'=>'是否开启订单奖励','isradio'=>1,'help'=>'开启前端显示，关闭前端不显示；'),
						array('type'=>'tip','title'=>'1、【按单笔订单奖励】：每笔订单奖励多少钱；2、【按配送商品个数奖励】：同订单多个商品，每个商品奖励多少钱'),
						array('type'=>'array','title'=>'订单奖励设置','name'=>'orderfee_set','add_tip'=>'添加一个订单奖励阶梯',
									'list'=>array(
										array('name'=>'level_id','title'=>'配送员等级','type'=>'select','help'=>'','options'=>'levels'),
										array('type'=>'radio','name'=>'type','title'=>'奖励方式','options'=>'orderfee_type'),
										array('type'=>'string','name'=>'fee','title'=>'配送订单奖励额度'),			
									),
									'details'=>array(
										array('name'=>'level_id','title'=>'配送员等级','type'=>'select','help'=>'','options'=>'levels'),
										array('type'=>'radio','name'=>'type','title'=>'奖励方式','options'=>'orderfee_type'),
										array('type'=>'string','name'=>'fee','title'=>'配送订单奖励额度'),
									)
						),
					)
			),*/
			array(
				'title'=>'当天配送超额奖励',
				'list'=>array(
						array('type'=>'switch','name'=>'tiemfee_open','title'=>'是否开启配送超额奖励','isradio'=>1,'help'=>'开启前端显示，关闭前端不显示；'),
						array('type'=>'array','title'=>'配送超额奖励设置','name'=>'tiemfee_set','add_tip'=>'添加一个超额奖励阶梯',
									'list'=>array(
										array('type'=>'string','name'=>'goodsnum','title'=>'当天配送达到N个商品'),
										array('type'=>'string','name'=>'fee','title'=>'奖励(配送费)'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'goodsnum','title'=>'当天配送达到N个商品'),
										array('type'=>'string','name'=>'fee','title'=>'奖励(配送费)'),	
									)
						),
					)
			),
			array(
				'title'=>'配送五星好评奖励',
				'list'=>array(
						array('type'=>'switch','name'=>'starfee_open','title'=>'是否开启五星好评奖励','isradio'=>1,'help'=>'开启前端显示，关闭前端不显示；'),
						array('type'=>'unitstring','unit'=>'元','name'=>'starfee_par','title'=>'奖励(配送费)','help'=>'每次获得客户一个五星好评奖励**元'),	
					)
			),
			array(
				'title'=>'差评处罚',
				'list'=>array(
						array('type'=>'switch','name'=>'chafee_open','title'=>'是否开启差评处罚','isradio'=>1,'help'=>'开启前端显示，关闭前端不显示；'),
						array('type'=>'unitstring','unit'=>'元','name'=>'chafee_par','title'=>'处罚(配送费)','help'=>'每次收到客户一个差评处罚**元'),	
					)
			),
			array(
				'title'=>'上门自提商品减额设置',
				'list'=>array(
					array('type'=>'unitstring','unit'=>'元','name'=>'pei_delgoodsfee','title'=>'（套餐商品时）上门自提每个商品减少**元/个','help'=>'上门自提每个商品减少**元/个，如果一个单有多个商品，那就多个商品都减少**元/个'),
				)
			),
			array(
				'title'=>'底部导航',
					'list'=>array(
									array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标','help'=>'图标，例如：icon-shouye'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
		)
	);
	$return['levels']=$this->getall('level',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid),array('id','title'),'id');
	$return['levels']['0']=array('id'=>0,'title'=>'默认等级');
	$return['orderfee_type']=$this->orderfee_type;
	$return['leveltype']=$this->level_up_types;
	$return['withdraw']=$this->pay_types;
	$return['peifeeshow']=$this->peifeeshow;
	$return['peifeetype']=$this->peifeetype;
	$return['become_child']=$this->become_child;
	$return['htmls']=$htmls;
	exi($return);
}